import json
from urllib.parse import urljoin
import requests

# 配置
REPO_URL = "https://gitee.com/he-miaoyuan/office-assistant-release.git"  # 替换为你的Gitee仓库地址
VERSION_FILE = "version.json"  # 版本信息文件
UPDATE_INTERVAL = 3600  # 检查更新间隔(秒)


def get_latest_version():
    """从Gitee获取最新版本信息"""

    # 尝试从raw.gitee.com获取版本文件
    raw_url = urljoin(REPO_URL.replace(
        "gitee.com", "raw.gitee.com") + "/", VERSION_FILE)

    headers = {"User-Agent": "Python Update Checker"}
    response = requests.get(raw_url, headers=headers, timeout=10)
    if response.status_code == 200:
        return json.loads(response.text)
    return None


# 使用示例
if __name__ == "__main__":
    get_latest_version()
